#File Name: appendix_figures.R
#Data: SFGSII_mdr_exp_paper_forR.dta from main_text.do
#Purpose: Draw figures for Richardson, "Politicization and Expertise: Exit, Effort, and Investment" in the appendix
#Output: Figures for the appendix
#Date: 6/15/2017


setwd("G:/")
library(readstata13)

sfgs<-read.dta13("Data/mdr/expertise_paper/SFGSII_mdr_exp_paper_forR.dta",convert.factors = F)
a<-sfgs[sfgs$exp_drop==0,]
#############################################################################################
#Distributions of Key Variables - full and models; Section 3 ####
#############################################################################################

#Exit ####
m<-sfgs[sfgs$sample3==1,]

pdf(file="C:/Users/richar33/Dropbox/Papers/expertise/paper/Figures/exit.pdf",width=14,height=7)
par(mfrow=c(1,2),cex.lab=1.5,cex.axis=1.5,las=1,mar=c(5,4.5,4,2)+0.1,cex.main=1.5)

t<-table(a$leave_likelihood)
tc<-as.character(t)
bp<-barplot(t,ylab="", xlab="Intent to Exit",main="All Observations",names.arg=c("Very unlikely", "Unlikely", "Likely", "Very likely"))
title(ylab="Frequency", line=3.5) #adjust distance of y-axis label from text.
sp<-30
text(bp,(t+sp),tc,xpd=NA,cex=1.3)

t<-table(m$leave_likelihood)
tc<-as.character(t)
bp<-barplot(t,ylab="", xlab="Intent to Exit",main="Observations in Model 3",
            names.arg=c("Very unlikely", "Unlikely", "Likely", "Very likely"),ylim=c(0,1000))
title(ylab="Frequency", line=3.5) #adjust distance of y-axis label from text.
sp<-30
text(bp,(t+sp),tc,xpd=NA,cex=1.3)

dev.off()

#Workhours - intervals are left closed, so included 40-44,45-49,etc. ####

pdf(file="C:/Users/richar33/Dropbox/Papers/expertise/paper/Figures/effort.pdf",width=14,height=7)
par(mfrow=c(1,2),cex.lab=1.5,cex.axis=1.5,las=1,mar=c(5,4.5,4,2)+0.1,cex.main=1.5)

hist(a$workhours_per_week,breaks=seq(from=15,to=105,by=5),labels=T,main="All Observations",right=F, 
     xlab="Hours Usually Worked Per Week",col="gray", ylim=c(0,425),ylab="")
title(ylab="Frequency", line=3.5) #adjust distance of y-axis label from text.


m<-sfgs[sfgs$sample4==1,]

hist(m$workhours_per_week,breaks=seq(from=18,to=105,by=5),labels=T,main="Observations in Model 4",right=F, 
     xlab="Hours Usually Worked Per Week",col="gray",ylim=c(0,425),ylab="")
title(ylab="Frequency", line=3.5) #adjust distance of y-axis label from text.

dev.off()

#Politicization ####
pdf(file="C:/Users/richar33/Dropbox/Papers/expertise/Paper/Figures/pol.pdf",width=14,height=7)
par(mfrow=c(1,2),cex.lab=1.5,cex.axis=1.5,las=1,mar=c(5,4.5,4,2)+0.1,cex.main=1.5)

t<-table(a$politicized_app)
tc<-as.character(t)
bp<-barplot(t,ylab="", xlab="Perceived Politicization",ylim=c(0,1000),main="All Observations")
title(ylab="Frequency", line=3.5) #adjust distance of y-axis label from text.
sp<-25
text(bp,(t+sp),tc,xpd=NA,cex=1.3)

m<-sfgs[sfgs$sample1==1,]

t<-table(m$politicized_app)
tc<-as.character(t)
bp<-barplot(t,ylab="", xlab="Perceived Politicization",ylim=c(0,1000),main="Observations in Model 1")
title(ylab="Frequency", line=3.5) #adjust distance of y-axis label from text.
sp<-25
text(bp,(t+sp),tc,xpd=NA,cex=1.3)

dev.off()

#Divergence ####
table(is.na(a$div_ip))

pdf(file="C:/Users/richar33/Dropbox/Papers/expertise/Paper/Figures/div.pdf",width=14,height=7)
par(mfrow=c(1,2),cex.lab=1.5,cex.axis=1.5,las=1,mar=c(5,4.5,4,2)+0.1,cex.main=1.5)

plot(density(a$div_ip,na.rm=T),xlim=c(0,4),xlab="Preference Divergence (N = 2,342)",
     main="All Observations",bty="l",ylim=c(0,.8))
abline(h=0)

table(is.na(m$div_ip))

plot(density(m$div_ip,na.rm=T),xlim=c(0,4),xlab="Preference Divergence (N = 1,630)",
     main="Observations in Model 1",bty="l",ylim=c(0,.8))
abline(h=0)

dev.off()

rm(m)

#Expertise Investment #### - all respondents
a<-sfgs[sfgs$exp_drop==0,]
ymax<-900
sp<-50
pdf(file="C:/Users/richar33/Dropbox/Papers/expertise/Paper/Figures/inv_dist_all_all.pdf",width=7,height=7)
par(mfrow=c(3,2),cex.lab=1,cex.axis=.8,las=1)

t<-table(a$inv_read)
tc<-as.character(t)
bp<-barplot(t,ylab="Frequency", main="Read professional or trade journals",ylim=c(0,ymax),
            names.arg=c("Never", "Rarely","Few times\n a year","Monthly","Weekly","Daily"))
text(bp,(t+sp),tc,xpd=NA)

t<-table(a$inv_outside_exp)
tc<-as.character(t)
bp<-barplot(t,ylab="Frequency", main="Discuss policy with outside experts",ylim=c(0,ymax),
            names.arg=c("Never", "Rarely","Few times\n a year","Monthly","Weekly","Daily"))
text(bp,(t+sp),tc,xpd=NA)

t<-table(a$inv_sme)
tc<-as.character(t)
bp<-barplot(t,ylab="Frequency", main="Consult subject matter experts",ylim=c(0,ymax),
            names.arg=c("Never", "Rarely","Few times\n a year","Monthly","Weekly","Daily"))
text(bp,(t+sp),tc,xpd=NA)

t<-table(a$inv_academic)
tc<-as.character(t)
bp<-barplot(t,ylab="Frequency", main="Conduct or read academic research",ylim=c(0,ymax),
            names.arg=c("Never", "Rarely","Few times\n a year","Monthly","Weekly","Daily"))
text(bp,(t+sp),tc,xpd=NA)

t<-table(a$inv_training)
tc<-as.character(t)
bp<-barplot(t,ylab="Frequency", main="Attend seminars or training",ylim=c(0,ymax),
            names.arg=c("Never", "Rarely","Few times\n a year","Monthly"))
text(bp,(t+sp),tc,xpd=NA)

t<-table(a$inv_conferences)
tc<-as.character(t)
bp<-barplot(t,ylab="Frequency", main="Attend industry or trade conferences",ylim=c(0,ymax),
            names.arg=c("Never", "Rarely","Few times\n a year","Monthly"))
text(bp,(t+sp),tc,xpd=NA)

dev.off()

#Expertise Investment #### - Table 2

ymax<-500
sp<-30
pdf(file="C:/Users/richar33/Dropbox/Papers/expertise/Paper/Figures/inv_dist_models_all.pdf",width=7,height=7)
par(mfrow=c(2,2),cex.lab=1,cex.axis=.55,las=1)

m<-sfgs[sfgs$sample_inv_outside_exp==1,]
t<-table(m$inv_outside_exp)
tc<-as.character(t)
bp<-barplot(t,ylab="Frequency", main="Discuss policy with outside experts",ylim=c(0,ymax),names.arg=c("Never", "Rarely","Few times\n a year","Monthly","Weekly","Daily"))
text(bp,(t+sp),tc,xpd=NA)

m<-sfgs[sfgs$sample_inv_sme==1,]
t<-table(m$inv_sme)
tc<-as.character(t)
bp<-barplot(t,ylab="Frequency", main="Consult subject matter experts",ylim=c(0,ymax),names.arg=c("Never", "Rarely","Few times\n a year","Monthly","Weekly","Daily"))
text(bp,(t+sp),tc,xpd=NA)

m<-sfgs[sfgs$sample_inv_training==1,]
t<-table(m$inv_training)
tc<-as.character(t)
bp<-barplot(t,ylab="Frequency", main="Attend seminars or training",ylim=c(0,ymax),names.arg=c("Never", "Rarely","Few times\n a year","Monthly"))
text(bp,(t+sp),tc,xpd=NA)

m<-sfgs[sfgs$sample_fact_all==1,]
plot(density(m$investment_all,na.rm=T),xlab="Investment Factor Score (N = 763)",
     main="Factor Score",bty="l",ylim=c(0,.8),cex.axis=1)
abline(h=0)

dev.off()

#############################################################################################
#Scatter plots ####
#############################################################################################

#Politicization and Exit ####
pdf(file="C:/Users/richar33/Dropbox/Papers/expertise/Paper/Figures/pol_leave.pdf",width=14,height=7)
par(mfrow=c(1,2),cex.lab=1.4,cex.axis=1.4,cex.main=1.4)
plot(jitter(a$politicized_app),jitter(a$leave_likelihood),xlab="Perceived Politicization",
     ylab="Intent to Exit",yaxt="n",main="All Observations")
lines(loess.smooth(a$politicized_app,a$leave_likelihood,degree=2,span=2),lwd=2)
axis(side=2,at=0:3, labels=c("Very\nUnlikely","Unlikely","Likely","Very\nlikely"))

m<-sfgs[sfgs$sample3==1,]

plot(jitter(m$politicized_app),jitter(m$leave_likelihood),xlab="Perceived Politicization",
     ylab="Intent to Exit",yaxt="n",main="Observations in Model 3")
lines(loess.smooth(m$politicized_app,m$leave_likelihood,degree=2,span=2),lwd=2)
axis(side=2,at=0:3, labels=c("Very\nUnlikely","Unlikely","Likely","Very\nlikely"))

dev.off()

#Politicization and Effort ####
pdf(file="C:/Users/richar33/Dropbox/Papers/expertise/Paper/Figures/pol_effort.pdf",width=14,height=7)
par(mfrow=c(1,2),cex.lab=1.4,cex.axis=1.4,cex.main=1.4)

plot(jitter(a$politicized_app),jitter(a$workhours_per_week),main="All Observations",
     xlab="Perceived Politicization",ylab="Hours Typically Worked Per Week",ylim=c(19,100))
abline(lm(a$workhours_per_week~a$politicized_app),lwd=2)
#lines(loess.smooth(a$politicized_app,a$workhours_per_week, degree=2, span=2))

m<-sfgs[sfgs$sample4==1,]
plot(jitter(m$politicized_app),jitter(m$workhours_per_week),main="Observations in Model 4",
     xlab="Perceived Politicization",ylab="Hours Typically Worked Per Week",ylim=c(19,100))
abline(lm(m$workhours_per_week~m$politicized_app),lwd=2)
#lines(loess.smooth(m$politicized_app,m$workhours_per_week, degree=2, span=2))

dev.off()

#Divergence and Politicization ####
pdf(file="C:/Users/richar33/Dropbox/Papers/expertise/Paper/Figures/div_pol.pdf",width=14,height=7)
par(mfrow=c(1,2),cex.lab=1.4,cex.axis=1.4,cex.main=1.4)

plot(a$div_ip,jitter(a$politicized_app),xlab="Preference Divergence",ylab="Perceived Politicization",
     main="All Observations",xlim=c(0,3.75))
lines(loess.smooth(a$div_ip,a$politicized_app),lwd=2)

m<-sfgs[sfgs$sample1==1,]
plot(m$div_ip,jitter(m$politicized_app),xlab="Preference Divergence",ylab="Perceived Politicization",
     main="Observations in Model 1",xlim=c(0,3.75))
lines(loess.smooth(m$div_ip,m$politicized_app),lwd=2)

dev.off()



pdf(file="C:/Users/richar33/Dropbox/Papers/expertise/Paper/Figures/pol_inv_models.pdf",width=14,height=21)
par(mfrow=c(3,2),cex.lab=2.5,cex.axis=2,cex.main=2.5,mar=c(5,5,4,2)+0.1)

m<-sfgs[sfgs$sample_inv_read==1,]
plot(jitter(m$politicized_app),jitter(m$inv_read),xlab="Perceived Politicization",
     ylab="Investment Frequency", main="Read professional or trade journals",cex=2)
lines(loess.smooth(m$politicized_app,m$inv_read,span=2,degree=2),lwd=2)

m<-sfgs[sfgs$sample_inv_outside_exp==1,]
plot(jitter(m$politicized_app),jitter(m$inv_outside_exp),xlab="Perceived Politicization",
     ylab="Investment Frequency", main="Discuss policy with outside experts",cex=2)
lines(loess.smooth(m$politicized_app,m$inv_outside_exp,span=2,degree=2),lwd=2)
#abline(lm(m$inv_outside_exp~m$politicized_app),lwd=2)

m<-sfgs[sfgs$sample_inv_sme==1,]
plot(jitter(m$politicized_app),jitter(m$inv_sme),xlab="Perceived Politicization",
     ylab="Investment Frequency", main="Consult Subject matter experts",cex=2)
lines(loess.smooth(m$politicized_app,m$inv_sme,span=2,degree=2),lwd=2)

m<-sfgs[sfgs$sample_inv_academic==1,]
plot(jitter(m$politicized_app),jitter(m$inv_academic),xlab="Perceived Politicization",
     ylab="Investment Frequency", main="Conduct or read academic research",cex=2)
lines(loess.smooth(m$politicized_app,m$inv_sme,span=2,degree=2),lwd=2)

m<-sfgs[sfgs$sample_inv_training==1,]
plot(jitter(m$politicized_app),jitter(m$inv_training),xlab="Perceived Politicization",
     ylab="Investment Frequency",yaxt="n", main="Attend seminars or training",cex=2)
axis(side=2,at=0:3)
lines(loess.smooth(m$politicized_app,m$inv_training,span=2,degree=2),lwd=2)

m<-sfgs[sfgs$sample_inv_conferences==1,]
plot(jitter(m$politicized_app),jitter(m$inv_conferences),xlab="Perceived Politicization",
     ylab="Investment Frequency",yaxt="n", main="Attend industry or trade conferences",cex=2)
axis(side=2,at=0:3)
lines(loess.smooth(m$politicized_app,m$inv_conferences,span=2,degree=2),lwd=2)

dev.off()


#####################################################################################
#Politicization and Investment - All ####
#####################################################################################


a<-sfgs[sfgs$exp_drop==0,]

pdf(file="C:/Users/richar33/Dropbox/Papers/expertise/Paper/Figures/pol_inv_all_all.pdf",width=14,height=14)
par(mfrow=c(2,2),cex.lab=2.5,cex.axis=2,cex.main=2.5,mar=c(5,5,4,2)+0.1)

plot(jitter(a$politicized_app),jitter(a$inv_outside_exp),xlab="Perceived Politicization",
     ylab="Investment Frequency", main="Discuss policy with outside experts",cex=2)
lines(loess.smooth(a$politicized_app,a$inv_outside_exp,span=2,degree=2),lwd=2)
#abline(lm(a$inv_outside_exp~a$politicized_app),lwd=2)

plot(jitter(a$politicized_app),jitter(a$inv_sme),xlab="Perceived Politicization",
     ylab="Investment Frequency", main="Consult subject matter experts",cex=2)
lines(loess.smooth(a$politicized_app,a$inv_sme,span=2,degree=2),lwd=2)

plot(jitter(a$politicized_app),jitter(a$inv_training),xlab="Perceived Politicization",
     ylab="Investment Frequency",yaxt="n", main="Attend seminars or training",cex=2)
lines(loess.smooth(a$politicized_app,a$inv_training,span=2,degree=2),lwd=2)
axis(side=2,at=0:5)

plot(jitter(m$politicized_app),jitter(m$investment_all),xlab="Perceived Politicization",
     ylab="Investment Frequency",yaxt="n", main="Factor Score",cex=2,ylim=c(-2.75,2.75))
abline(lm(m$investment_all~m$politicized_app))
axis(side=2,at=-3:3)

dev.off()

pdf(file="C:/Users/richar33/Dropbox/Papers/expertise/Paper/Figures/pol_inv_model_all.pdf",width=14,height=14)
par(mfrow=c(2,2),cex.lab=2.5,cex.axis=2,cex.main=2.5,mar=c(5,5,4,2)+0.1)

m<-sfgs[sfgs$sample_inv_outside_exp==1,]
plot(jitter(m$politicized_app),jitter(m$inv_outside_exp),xlab="Perceived Politicization",
     ylab="Investment Frequency", main="Discuss policy with outside experts",cex=2)
lines(loess.smooth(a$politicized_app,a$inv_outside_exp,span=2,degree=2),lwd=2)
#abline(lm(a$inv_outside_exp~a$politicized_app),lwd=2)

m<-sfgs[sfgs$sample_inv_sme==1,]
plot(jitter(m$politicized_app),jitter(m$inv_sme),xlab="Perceived Politicization",
     ylab="Investment Frequency", main="Consult Subject matter experts",cex=2)
lines(loess.smooth(m$politicized_app,m$inv_sme,span=2,degree=2),lwd=2)

m<-sfgs[sfgs$sample_inv_training==1,]
plot(jitter(m$politicized_app),jitter(m$inv_training),xlab="Perceived Politicization",
     ylab="Investment Frequency",yaxt="n", main="Attend seminars or training",cex=2)
axis(side=2,at=0:3)
lines(loess.smooth(m$politicized_app,m$inv_training,span=2,degree=2),lwd=2)

m<-sfgs[sfgs$sample_fact_all==1,]
plot(jitter(m$politicized_app),jitter(m$investment_all),xlab="Perceived Politicization",
     ylab="Investment Frequency",yaxt="n", main="Factor Score",cex=2,ylim=c(-2.75,2.75))
axis(side=2,at=-3:3)
abline(lm(m$investment_all~m$politicized_app))

dev.off()

#####################################################################################
#Investment by mission ####
#####################################################################################

setwd("G:/")
library(readstata13)

m<-read.dta13("Data/mdr/expertise_paper/SFGSII_mdr_exp_mission.dta",convert.factors = F)

xlb<- -4.5
clb<- 0.65

#read
m<-m[order(m$inv_read),]
m$lb<-m$inv_read-1.96*m$se_read
m$ub<-m$inv_read+1.96*m$se_read

#t-value at 95% ci for n=19 & df=18
m$lb[m$mission==450]<-m$inv_read[m$mission==450]-2.101*m$se_read[m$mission==450]
m$ub[m$mission==450]<-m$inv_read[m$mission==450]+2.101*m$se_read[m$mission==450]

pdf(file="C:/Users/richar33/Dropbox/Papers/expertise/Paper/Figures/mission_read.pdf",width=7,height=5)
par(cex.axis=clb)
plot(m$inv_read,1:15,xlim=c(xlb,5),ylab="",xlab="Frequency",main="Read professional or trade journals",pch=19,yaxt="n",xaxt="n",bty="]")
segments(m$lb,1:15,m$ub,1:15)
text(1,1:15,m$m_text,pos=2)
axis(side=1, at=0:5,labels=c("Never","Rarely","Few times\nper year","Monthly","Weekly","Daily"))
abline(v=1:5,lty=2)
dev.off()

#outside
m<-m[order(m$inv_outside_exp),]
m$lb<-m$inv_outside_exp-1.96*m$se_outside
m$ub<-m$inv_outside_exp+1.96*m$se_outside

#t-value at 95% ci for n=19 & df=18
m$lb[m$mission==450]<-m$inv_outside_exp[m$mission==450]-2.101*m$se_outside[m$mission==450]
m$ub[m$mission==450]<-m$inv_outside_exp[m$mission==450]+2.101*m$se_outside[m$mission==450]

pdf(file="C:/Users/mdr/Dropbox/Papers/expertise/Paper/Figures/mission_outside_exp.pdf",width=7,height=5)
par(cex.axis=clb)
plot(m$inv_outside_exp,1:15,xlim=c(xlb,5),ylab="",xlab="Frequency",main="Discuss policy with outside experts",pch=19,yaxt="n",xaxt="n",bty="]")
segments(m$lb,1:15,m$ub,1:15)
text(1,1:15,m$m_text,pos=2)
axis(side=1, at=0:5,labels=c("Never","Rarely","Few times\nper year","Monthly","Weekly","Daily"))
abline(v=1:5,lty=2)
dev.off()

#sme
m<-m[order(m$inv_sme),]
m$lb<-m$inv_sme-1.96*m$se_sme
m$ub<-m$inv_sme+1.96*m$se_sme

#t-value at 95% ci for n=19 & df=18
m$lb[m$mission==450]<-m$inv_sme[m$mission==450]-2.101*m$se_sme[m$mission==450]
m$ub[m$mission==450]<-m$inv_sme[m$mission==450]+2.101*m$se_sme[m$mission==450]

pdf(file="C:/Users/mdr/Dropbox/Papers/expertise/Paper/Figures/mission_sme.pdf",width=7,height=5)
par(cex.axis=clb)
plot(m$inv_sme,1:15,xlim=c(xlb,5),ylab="",xlab="Frequency",main="Consult subject matter experts",pch=19,yaxt="n",xaxt="n",bty="]")
segments(m$lb,1:15,m$ub,1:15)
text(1,1:15,m$m_text,pos=2)
axis(side=1, at=0:5,labels=c("Never","Rarely","Few times\nper year","Monthly","Weekly","Daily"))
abline(v=1:5,lty=2)
dev.off()

#academic
m<-m[order(m$inv_academic),]
m$lb<-m$inv_academic-1.96*m$se_academic
m$ub<-m$inv_academic+1.96*m$se_academic

#t-value at 95% ci for n=19 & df=18
m$lb[m$mission==450]<-m$inv_academic[m$mission==450]-2.101*m$se_academic[m$mission==450]
m$ub[m$mission==450]<-m$inv_academic[m$mission==450]+2.101*m$se_academic[m$mission==450]

pdf(file="C:/Users/mdr/Dropbox/Papers/expertise/Paper/Figures/mission_academic.pdf",width=7,height=5)
par(cex.axis=clb)
plot(m$inv_academic,1:15,xlim=c(xlb,5),ylab="",xlab="Frequency",main="Conduct or read academic research",pch=19,yaxt="n",xaxt="n",bty="]")
segments(m$lb,1:15,m$ub,1:15)
text(1,1:15,m$m_text,pos=2)
axis(side=1, at=0:5,labels=c("Never","Rarely","Few times\nper year","Monthly","Weekly","Daily"))
abline(v=1:5,lty=2)
dev.off()

#training
m<-m[order(m$inv_training),]
m$lb<-m$inv_training-1.96*m$se_training
m$ub<-m$inv_training+1.96*m$se_training

#t-value at 95% ci for n=19 & df=18
m$lb[m$mission==450]<-m$inv_training[m$mission==450]-2.101*m$se_training[m$mission==450]
m$ub[m$mission==450]<-m$inv_training[m$mission==450]+2.101*m$se_training[m$mission==450]

pdf(file="C:/Users/mdr/Dropbox/Papers/expertise/Paper/Figures/mission_training.pdf",width=7,height=5)
par(cex.axis=clb)
plot(m$inv_training,1:15,xlim=c(xlb,5),ylab="",xlab="Frequency",main="Attend seminars or training",pch=19,yaxt="n",xaxt="n",bty="]")
segments(m$lb,1:15,m$ub,1:15)
text(1,1:15,m$m_text,pos=2)
axis(side=1, at=0:3,labels=c("Never","Rarely","Few times\nper year","Monthly"))
abline(v=1:3,lty=2)
dev.off()

#conferences
m<-m[order(m$inv_conferences),]
m$lb<-m$inv_conferences-1.96*m$se_conferences
m$ub<-m$inv_conferences+1.96*m$se_conferences

#t-value at 95% ci for n=19 & df=18
m$lb[m$mission==450]<-m$inv_conferences[m$mission==450]-2.101*m$se_conferences[m$mission==450]
m$ub[m$mission==450]<-m$inv_conferences[m$mission==450]+2.101*m$se_conferences[m$mission==450]

pdf(file="C:/Users/mdr/Dropbox/Papers/expertise/Paper/Figures/mission_conferences.pdf",width=7,height=5)
par(cex.axis=clb)
plot(m$inv_conferences,1:15,xlim=c(xlb,5),ylab="",xlab="Frequency",main="Attend industry or trade coferences",pch=19,yaxt="n",xaxt="n",bty="]")
segments(m$lb,1:15,m$ub,1:15)
text(1,1:15,m$m_text,pos=2)
axis(side=1, at=0:3,labels=c("Never","Rarely","Few times\nper year","Monthly"))
abline(v=1:3,lty=2)
dev.off()


#####################################################################################
#Politicization and Investment - Rulemakers ####
#####################################################################################


a<-sfgs[sfgs$job_rulemaking==1 & is.na(sfgs$job_rulemaking)==F & sfgs$exp_drop==0,]

pdf(file="C:/Users/richar33/Dropbox/Papers/expertise/Paper/Figures/pol_inv_all.pdf",width=14,height=21)
par(mfrow=c(3,2),cex.lab=2.5,cex.axis=2,cex.main=2.5,las=1,mar=c(5,5,4,2)+0.1)

plot(jitter(a$politicized_app),jitter(a$inv_read),xlab="Perceived Politicization",
     ylab="Investment Frequency",main="Read professional or trade journals",cex=2)
lines(loess.smooth(a$politicized_app,a$inv_read,span=2,degree=2),lwd=2)

plot(jitter(a$politicized_app),jitter(a$inv_outside_exp),xlab="Perceived Politicization",
     ylab="Investment Frequency", main="Discuss policy with outside experts",cex=2)
lines(loess.smooth(a$politicized_app,a$inv_outside_exp,span=2,degree=2),lwd=2)
#abline(lm(a$inv_outside_exp~a$politicized_app),lwd=2)

plot(jitter(a$politicized_app),jitter(a$inv_sme),xlab="Perceived Politicization",
     ylab="Investment Frequency", main="Consult subject matter experts",cex=2)
lines(loess.smooth(a$politicized_app,a$inv_sme,span=2,degree=2),lwd=2)

plot(jitter(a$politicized_app),jitter(a$inv_academic),xlab="Perceived Politicization",
     ylab="Investment Frequency", main="Conduct or read academic research",cex=2)
lines(loess.smooth(a$politicized_app,a$inv_sme,span=2,degree=2),lwd=2)

plot(jitter(a$politicized_app),jitter(a$inv_training),xlab="Perceived Politicization",
     ylab="Investment Frequency",yaxt="n", main="Attend seminars or training",cex=2)
lines(loess.smooth(a$politicized_app,a$inv_training,span=2,degree=2),lwd=2)
axis(side=2,at=0:5)

plot(jitter(a$politicized_app),jitter(a$inv_conferences),xlab="Perceived Politicization",
     ylab="Investment Frequency",yaxt="n", main="Attend industry or trade conferences",cex=2)
lines(loess.smooth(a$politicized_app,a$inv_conferences,span=2,degree=2),lwd=2)
axis(side=2,at=0:5)

dev.off()

